<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"  content="text/html; charset=utf-8" />
<link rel="stylesheet" href="all.css" type="text/css" media="screen" />
    <link rel="stylesheet" type="text/css" href="jquery.lightbox-0.5.css" media="screen" />
    <script src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery.lightbox-0.5.js"></script>
    <script src="edit.js"></script>
    <script src="login.js"></script>
    <script src="enter.js"></script>
<title>投票 - <c:out value="${leagueBean.name}" /></title>
<script type="text/javascript">

window.onload=function(){
	rightH=document.getElementById("xc_right").offsetHeight;
	if(rightH<600){
	document.getElementById("xc_left").style.height=600+"px";}
	else{
		document.getElementById("xc_left").style.height=rightH+"px";
	}
	var Request = new Object();
	Request = GetRequest();
	var msg;
	msg = Request['msg'];
	if(msg==1){
	alert("投票成功！谢谢您的参与！");}
	if(msg==3){
		alert("对不起，您的在此次活动中的投票已用完！");}
	if(msg==0){
		alert("您好，请先用普通用户身份登录！");}
	select();
}
$(function() {
	
	$('#right_xiangce .right_xiangce_xc1_lj').lightBox({fixedNavigation:true}); // Select all links in the page
	
});
</script>
</head>
<body>
<div id="main">
 <div id="header">
    <div id="header_inner">
        <div id="header_inner_top">
          <div id="container">
            <jsp:include page="./head.jsp" flush="true"/>
        </div>
        </div>
	</div>
 </div> 
	<div id="xc_body">
    	<div id="xc_left">
        	<div id="xc_left_left">
        		<div id="left_logo">
               		<a class="left_a" href="http://herald.seu.edu.cn" >
                 	
              		 </a>  
            	</div>
                <div id="left_platform">
               		<a class="left_a" href="http://herald.seu.edu.cn/league_p/" >
                 	
              		 </a>  
            	</div>
                <div id="left_home">
               		<a class="left_a" href="home.jsp?league=<%=request.getParameter("league") %>" >
                 	
              		 </a>  
            	</div>
                <div id="xc_left_information">
               		<a class="left_a" href="activities.jsp?league=<%=request.getParameter("league") %>" >
                 
              		 </a>  
            	</div>
                <div id="left_album">
               		<a class="left_a" href="albums.jsp?league=<%=request.getParameter("league") %>" >
                 	
              		 </a>  
            	</div>
                <div id="left_recruiting">
               		<a class="left_a" href="recruit.jsp?league=<%=request.getParameter("league") %>" >
                 	
              		 </a>  
            	</div>
                <div id="vote_left_polling">
               		<a class="left_a" href="javascript:void(0)"  >
                 
              		 </a>  
            	</div>
                <div id="left_guestbook">
               		<a class="left_a" href="guestbook.jsp?league=<%=request.getParameter("league") %>" >
                 	
              		 </a>  
            	</div>
    
            </div>
             <div id="xc_left_right">
             </div>
         </div>
         <div id="xc_right">
         	<div id="right_title_kuangjia">
         	<div id="right_title">
                <div id="right_title_name">
                   <p><c:out value="${leagueBean.name}" /></p>
                </div>
                <!--未登录  -->
                <c:if test="${leagueUserAuth == null&&commonUserAuth == null}">
                <div id="right_title_attention">
                	<div id="right_title_attention_plus">
                    </div>
                    <div id="right_title_attention_text">
                    <form id="attentionAddForm" action="./AttentionAdd">
                    <input name="league" type="hidden" value=<%=request.getParameter("league") %> />
                    <input name="url" type="hidden" id="url" value="" />
                    </form>
                        <a title="加关注" href="javascript:void(0)" onclick="javascript:alert('您好，请您先登录。')">加关注</a>
                    </div>
                </div>
                </c:if>
                <!--未加关注  -->
                <c:if test="${attention == false && leagueUserAuth == null && commonUserAuth != null}">
                <div id="right_title_attention">
                	
                    <div id="right_title_attention_text">
                    <form id="attentionAddForm" action="./AttentionAdd" onsubmit="return false;">
                    <input name="league" type="hidden" value=<%=request.getParameter("league") %> />
                    <input name="url" type="hidden" id="url" value="" />
                    </form>
                    
                        <a id="att" style="display:block" title="加关注&nbsp;&nbsp;" href="javascript:void(0)" onclick="javascript:attention(<%=request.getParameter("league") %>);"><div id="right_title_attention_plus">
                    </div>加关注</a>
                        <a id="cancleAtt" style="display:none" title="取消关注" href="javascript:void(0)" onclick="javascript:cancleAttention(<%=request.getParameter("league") %>);">取消关注</a>
                    </div>
                </div>
                </c:if>
                
                <!--已加关注-->
                <c:if test="${attention == true}">
                <div id="right_title_attention">
                    <div id="right_title_attention_text">
                    <form id="attentionDeleteForm" action="./AttentionDelete">
                    <input name="league" type="hidden" value=<%=request.getParameter("league") %> />
                    <input name="url" type="hidden" id="url" value="" />
                    </form>
                    <a id="att" style="display:none" title="加关注&nbsp;&nbsp;" href="javascript:void(0)" onclick="javascript:attention(<%=request.getParameter("league") %>);"><div id="right_title_attention_plus">
                    </div>加关注</a>
                    <a id="cancleAtt" style="display:block" title="取消关注" href="javascript:void(0)" onclick="javascript:cancleAttention(<%=request.getParameter("league") %>);">取消关注</a>
                    </div>
                </div>
                </c:if>
                
            </div>
            </div>
         
          <div id="right_xiangce">
                <div id="right_xiangce_title_kj">
          		<div id="right_xiangce_title">
                   <h1>投票</h1>
                </div>
                </div>
                <div id="right_vote_create_kj">
                <c:if test="${leagueUserAuth != null && param.league != null && leagueUserAuth.leagueId == param.league}">
                <div id="right_vote_create">
                 <c:if test="${vote.title!= null}">
                    <a href="javascript:void(0)" onclick="javascript:showDiv1()">删除投票活动</a>
                    <a href="javascript:void(0)" onclick="javascript:showDiv()">更换投票活动</a>
                    <a href="javascript:void(0)" onclick="javascript:showDiv3()">为本投票活动添加选项</a>
                 </c:if>
                 <c:if test="${vote.title== null}">
                	<a href="javascript:void(0)" onclick="javascript:showDiv()">发起投票活动</a>
                	</c:if>
                </div>
                </c:if>
                </div>
                <div id="right_xiangce_line_kj">
                <div id="right_xiangce_line">
                </div>
                </div>
                
                <!--投票活动名字  -->
                <div id="voteName">
                <c:if test="${vote.title!= null}">
                <c:out value="${vote.title}" /> &nbsp;&nbsp;&nbsp;(每人可投<c:out value="${vote.availableNumber}" />票)
                </c:if>
                 <c:if test="${leagueUserAuth != null && param.league != null && leagueUserAuth.leagueId == param.league}">
                <a href="javascript:void(0)" onclick="javascript:showDiv2()">修改名称</a>
                </c:if></div>
               
                <!---->
                
                <c:forEach items="${voteItems}" var="voteItem">
                <!--选项实体开始  -->
                <div class="picture_item">
                <div class="right_xiangce_caozuo_kj">
                <div class="right_xiangce_caozuo">
                 <c:if test="${leagueUserAuth != null && param.league != null && leagueUserAuth.leagueId == param.league}">
                	<div class="right_xiangce_bianji">
                		<a href="javascript:void(0)" onclick="javascript:showDivEdit(<c:out value="${voteItem.id}" />)">编辑</a>
                	</div>
                	</c:if>
                    <div class="right_xiangce_shanchu_kj">
                     <c:if test="${leagueUserAuth != null && param.league != null && leagueUserAuth.leagueId == param.league}">
                	<div class="right_xiangce_shanchu">
                		<a href="javascript:void(0)" onclick="javascript:showDivDelete(<c:out value="${voteItem.id}" />)">删除</a>
                	</div>
                	</c:if>
                    </div>
                 </div>
 				</div>
                
                <c:if test="${voteItem.picture!=null&&voteItem.picture!=''}">
                <div class="right_xiangce_xc1_kj">
                <div class="right_xiangce_xc1" >
                
                	<a class="right_xiangce_xc1_lj" href="<c:out value="${voteItem.picture}" />">
                		<img src="<c:out value="${voteItem.picture}" />" width="305" height="190" alt="" />
                    </a>   
                </div>
                </div>
                </c:if>
                <div class="right_xiangce_xc1_name_kj">
                <div class="right_xiangce_polling_name">
                   <div style="float:left;"><c:out value="${voteItem.name}" /></div>
                   <div style="float:right;height:13px;width:18px;"></div>
                   <div style="float:right;"><c:out value="${voteItem.count}" />票</div>
                </div>
                
                <div class="right_look_detail">
                 
                <div id="popDivDetail<c:out value="${voteItem.id}" />" class="mydiv" style="display:none;">
                <c:out value="${voteItem.content}" /><br>
                <a href="javascript:closeDivDetail(<c:out value="${voteItem.id}" />)">关闭</a></div>
                <div id="bg" class="bg" style="display:none;"></div> 
                </div>
                <a class="right_look_detail_link" href="javascript:void(0)" onclick="javascript:showDivDetail(<c:out value="${voteItem.id}" />)">查看介绍</a>
                <c:choose>
                <c:when test="${voteItem.polled}">
                <div class="right_write_polled">
                </div>
                </c:when>
                <c:otherwise>
                <div class="right_write_poll">
                <form id="poll_form<c:out value="${voteItem.id}" />" action="./VoteServlet" method="post" >
                 <input type="hidden" name="item" value="<c:out value="${voteItem.id}" />" />
                 <input type="hidden" name="league" value=<%=request.getParameter("league") %> />
                </form>
                <c:if test="${commonUserAuth != null}">
                    	<a class="right_write_poll_link" href="javascript:void(0)" onclick="document.getElementById('poll_form<c:out value="${voteItem.id}" />').submit();" >
                        </a>
                </c:if>
                 <c:if test="${commonUserAuth == null}">
                    	<a class="right_write_poll_link" href="javascript:void(0)" onclick="alert('登录后才可以投票的哇');" >
                        </a>
                </c:if>
                </div>
                </c:otherwise>
                </c:choose>
                </div>
                </div>
                <!--投票实体结束 -->
                </c:forEach>
                
          </div>
     </div>   
     
<div id="popDiv1" class="mydiv" style="display:none;">删除投票活动
<form action="./VoteDelete" method="post">
         
    <input type="submit" value="确定" name="submit">
    <a href="javascript:closeDiv1()">关闭</a></div>
</form>

<div id="bg" class="bg" style="display:none;"></div>

 
<div id="popDiv2" class="mydiv" style="display:none;">修改名称
<form action="./VoteTitleEdit" method="post">
          投票名称：<input type="text" name="voteName" ><br>     
    <input type="submit" value="确定" name="submit">
    <a href="javascript:closeDiv2()">关闭</a></div>
</form>

<div id="bg" class="bg" style="display:none;"></div>   
   
     
     
<div id="popDiv" class="mydiv" style="display:none;">更换投票活动
<form action="./VoteConvert" method="post"  onsubmit="return isNum('availableNumber');">
           投票名称：<input type="text" name="voteName" ><br>
           一个投票者可用票数：<input id="availableNumber" type="text" name="availableNumber" /><br>
    <input type="submit" value="提交" name="submit" />
    <a href="javascript:closeDiv()">关闭</a></div>
</form>

<div id="bg" class="bg" style="display:none;"></div>
      
     
     
<div id="popDivEdit" class="mydiv" style="display:none;">修改选项
<form  action="VoteItemUpdate" method="post" enctype="multipart/form-data">
	   
    <input id="edit_item_id" type="hidden" name="itemId" value="0">
    <div id="uploadForm">
    <p>   
           选项名称：<input type="text" name="itemName" ><br>
           选项描述：<textarea name="itemContent" ></textarea><br>
           上传图片：<input type="file" name="fileforload" >
    </p>
    </div>
    <input type="submit" value="确定" name="submit">
    <a href="javascript:closeDivEdit()">关闭</a></div>
 </form>

<div id="bg" class="bg" style="display:none;"></div>

<div id="popDivDel" class="mydiv" style="display:none;">
确定删除选项？
<form  action="./VoteItemDelete" method="post" >
    
    <input id="del_item_id" type="hidden" name="itemId" value="0">
    <input type="submit" value="确定" name="submit">
    <a href="javascript:closeDivDelete()">取消</a></div>
</form>

<div id="bg" class="bg" style="display:none;"></div> 



<div id="popDiv3" class="mydiv" style="display:none;" >添加选项
<form  action="VoteItemAdd" method="post" enctype="multipart/form-data">
    <div id="uploadForm">
    <p>
    <input type="hidden" name="voteId" value="<c:out value="${vote.id}" />"> 
           选项名称：<input type="text" name="itemName" ><br>
           选项描述：<textarea name="itemContent" ></textarea><br>
           上传图片：<input type="file" name="fileforload" >
    </p>
    </div>
    <input type="submit" value="提交" name="submit">
    <a href="javascript:closeDiv3()">关闭</a></div>
  </form>

<div id="bg" class="bg" style="display:none;"></div>  
  
</div>
         <div class="clear">
         </div>     
  
     
 <jsp:include page="./footer.jsp" flush="true"/> 
</div>
</body>
</html>
